<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
 

<t:datagrid name="scoreManageList" title="分数管理" actionUrl="ScoreManageController.do?scoreManageDatagrid" 
    fit="true" fitColumns="true" idField="id" queryMode="group" rowStyler="scoreRoleStyle">
	<t:dgCol title="分数ID"  field="id" hidden="true"    queryMode="single"  width="120"></t:dgCol>
	<t:dgCol title="学期" field="semesterInfo.semesterName" hidden="true" query='false' replace="${semester}"></t:dgCol>
	<t:dgCol title="学号"  field="student.staffNo" query="true"  width="120"></t:dgCol>
 	<t:dgCol title="姓名" field="student.realName" query="false" width="120"></t:dgCol>
	<t:dgCol title="班级"  field="student.className" query="true"   queryMode="single"  width="120"></t:dgCol>
	<t:dgCol title="创建人"  field="createUser.realName" query="false"   queryMode="single"  width="120"></t:dgCol>
	<t:dgCol title="实验课程"  field="lessonInfo.lessonName"  query="true"  queryMode="single"  width="120"></t:dgCol>		
	<t:dgCol title="项目分数"  hidden="false" field="itemScoreDetail"   formatterjs="getItemScore" queryMode="single"  width="220"></t:dgCol>	
		
	<t:dgCol title="项目1分数"  hidden="true" field="item1Score"   queryMode="single"  width="80"></t:dgCol>	
	<t:dgCol title="项目2分数"  hidden="true" field="item2Score"   queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目3分数"  hidden="true" field="item3Score"   queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目4分数"  hidden="true" field="item4Score"   queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目5分数"  hidden="true" field="item5Score"   queryMode="single"  width="80"></t:dgCol>		 
	
	<t:dgCol title="项目1"  field="item1Name"  hidden="true"  queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目2"  field="item2Name"  hidden="true"  queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目3"  field="item3Name"  hidden="true"  queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目4"  field="item4Name"  hidden="true"  queryMode="single"  width="80"></t:dgCol>
	<t:dgCol title="项目5"  field="item5Name"  hidden="true"  queryMode="single"  width="80"></t:dgCol>
	
	<t:dgCol title="总分数"  field="finalScore"   formatterjs="getScore" queryMode="single"  width="120"></t:dgCol> 
	<t:dgCol title="common.operation" field="opt"  width="120"></t:dgCol>
	<t:dgFunOpt  funname="setScore(id)" title="编辑分数" />
	<t:dgDelOpt title="删除" url="ScoreManageController.do?doDel&id={id}" />
	<t:dgToolBar title="添加学生分数" icon="icon-add" funname="addScore"></t:dgToolBar>
	<t:dgToolBar title="导入学生成绩" icon="icon-put" funname="ImportXls"></t:dgToolBar> 
	<t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
	<t:dgToolBar title="导出模板" icon="icon-putout" funname="ExportXlsTemplate"></t:dgToolBar>
 </t:datagrid>

<script type="text/javascript">

//导入
function ImportXls() {
	openuploadwin('Excel导入', 'ScoreManageController.do?upload', "dictCategoryList");
}   


function scoreRoleStyle(index,row){	
	if(row.finalScore < 60){
		return "background-color:#d15b47;color:white";	
	}
}   
   
function getItemScore(v,rec){
	var result = '';
	if(rec['item1Name'] != '') result +=(rec['item1Name']+":"+rec['item1Score']+",");
	if(rec['item2Name'] != '') result +=(rec['item2Name']+":"+rec['item2Score']+",");
	if(rec['item3Name'] != '') result +=(rec['item3Name']+":"+rec['item3Score']+",");
	if(rec['item4Name'] != '') result +=(rec['item4Name']+":"+rec['item4Score']+",");
	if(rec['item5Name'] != '') result +=(rec['item5Name']+":"+rec['item5Score']);
	return result;
}   
   
function getScore(v,rec,index){
	
	
	if(v =="" || v =="0"){
		return "--";
	}else{
		return v;
	}
}

//导出
function ExportXls() {
	var currentId = "${current.id}";
	var semester = currentId;	
	JeecgExcelExport("ScoreManageController.do?exportXls&semester="+semester,"scoreManageList");
}

//导出模板
function ExportXlsTemplate() {
	JeecgExcelExport("ScoreManageController.do?exportXlsTemplate","scoreManageList");
}

function downLoadTemplate(){
	window.location.href="studentController.do?exportTemplate";
}
 

 function addScore(){
	 setScore("");
 }
    
 function setScore(id){
    	/* var semester = $("select[name='semesterInfo']").val();
    	if(semester.length == 0){
    		var currentId = "${current.id}";
    		if(currentId.length == 0){
    			tip('未设置当前学期，无法设置分数');
        		return; 
    		}else{
    			semester = currentId;
    		}
    	}*/
    	
    	var currentId = "${current.id}";
    	var semester = currentId;    	
    	var url="ScoreManageController.do?&goSetScore&semesterId="+semester+"&id="+id;
    	add("设置学生分数", url, 'categoryList', 560, 440); 
    	 
   }


 
</script>
